var gulp = require('gulp')
var babel = require('gulp-babel')
var rename = require('gulp-rename')

gulp.task('member',function(){
	publicDeal()
	gulp.watch('./member/Member.js',function(){

	  	gulp.src('./member/Member.js')
		.pipe(babel({
			presets:['es2015']
		}))
		.pipe(rename({
			suffix:".build"
		}))
		.pipe(gulp.dest('./member'))
	})	
})

gulp.task('business',function(){
	publicDeal()
	gulp.watch('./business/Business.js',function(){

	  	gulp.src('./business/Business.js')
		.pipe(babel({
			presets:['es2015']
		}))
		.pipe(rename({
			suffix:".build"
		}))
		.pipe(gulp.dest('./business'))
	})	
})

gulp.task('businessintro',function(){
	publicDeal()
	gulp.watch('./businessintro/Businessintro.js',function(){

	  	gulp.src('./businessintro/Businessintro.js')
		.pipe(babel({
			presets:['es2015']
		}))
		.pipe(rename({
			suffix:".build"
		}))
		.pipe(gulp.dest('./businessintro'))
	})	
})

function publicDeal(){
	gulp.watch('./Public.js',function(){
		gulp.src('./Public.js')
		.pipe(babel({
			presets:['es2015']
		}))
		.pipe(rename({
			suffix:".build"
		}))
		.pipe(gulp.dest('./'))
	})
}